package org.example.flink.operation;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import javax.crypto.spec.PSource;
import java.util.List;

public class Hello02CommonStream {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();

        //获取数据源--基于File
//        DataStreamSource<String> source = environment.readTextFile("data/wordcount.txt");

        //获取数据源--基于Socket
//        DataStreamSource<String> source = environment.socketTextStream("localhost", 19523);

        //获取数据源--基于Collection
//        List<String> list = List.of("a", "b", "c");
//        DataStreamSource<String> source = environment.fromCollection(list);
//        source.map(word -> word.toUpperCase()).print();

        environment.fromElements("hello", "world").map(word -> word.toUpperCase()).print();

        environment.execute();
    }
}
